var root = ui("$");
var app = sm("do_App");
var do_Page = sm("do_Page");
var nf = sm("do_Notification");
var do_GridView_1 = ui("do_GridView_1");
var deviceone = require("deviceone");
var pubUrl = require("url/pub");
var httpUrl = pubUrl.url.concern.doCancle;
var qqHttp = require("helper/http");
var helperOpen = require("helper/open");
var bizzType = require("helper/bizzType");

//UI
var buttonDel=ui("buttonDel");
var labelContent=ui("labelContent");
//设置数据绑定的映射关系
root.setMapping({   // 此处的Mapping只能设置在 RootView 上 ;
	"labelContent.tag" : "id",
    "labelContent.text" : "bizzContent",
    "labelTime.text" : "cnNewAt",
    "do_GridView_1.items" : "imgItems",
    "do_GridView_1.tag" : "bigImgItems",
    "do_GridView_1.visible" : "hasImg",
    "linearLayout_1.tag" : "bizzId",
    "labelTime.tag" : "bizzType",
    "lableBizzTypeName.text" : "bizzTypeName"
});

//图片浏览注册事件
do_GridView_1.on("touch", function(data){
	helperOpen.open("source://view/reuse/imgBrowser.ui", {
		imgDatas :do_GridView_1.tag,index:data
	});
})
ui("linearLayout_1").on("touch",function(){
	var bizzId = ui("linearLayout_1").tag;
	var type= ui("labelTime").tag;
	if(type == bizzType.Level2.CIRCLE_TOPIC){
		helperOpen.open("source://view/circle/topic/detail/topicBorderView.ui",{topicId:bizzId});
	}else if(type == bizzType.Level2.COMMUNITY_MESSAGE){
		helperOpen.open("source://view/community/message/detail/msgBorderView.ui",{id:bizzId});
	}else if(type == bizzType.Level2.MALL_PRODUCT){
		helperOpen.open("source://view/mall/product/main.ui",{id:bizzId});
	}else if(type == bizzType.Level2.USER_TOPIC){
		
	}else if(type == bizzType.Level2.QSHOP_SHOP){
		helperOpen.open("source://view/qshop/detail/main.ui",{shopId:bizzId});
	}
	
})
buttonDel.on("touch",function(){
	nf.confirm("您确实要取消关注吗？", "取消收藏", "确定", "取消", function(data, e) {
		if(data == 1){
			cancleConcern();
		}
	})
})
function cancleConcern(){
	var params = {
		id: labelContent.tag
	};
	qqHttp.post(httpUrl, params, function(data) {
		nf.toast("已取消");
		do_Page.fire("cancleConcern",labelContent.tag);
	})
}